<?php

	require('connect.php');
	$fdesde = str_replace("-", "", date('Y-m-d'));
	$query = "SELECT ID as Id		FROM EnvironmentalDaily		where CONVERT(VARCHAR(8), TrnDate, 112)   = '$fdesde'";

	
$stmt = sqlsrv_query( $conn, $query);
if( $stmt === false ) {
     die( print_r( sqlsrv_errors(), true));
}

// Make the first (and in this case, only) row of the result set available for reading.
if( sqlsrv_fetch( $stmt ) === false) {
     die( print_r( sqlsrv_errors(), true));
}

// Get the row fields. Field indeces start at 0 and must be retrieved in order.
// Retrieving row fields by name is not supported by sqlsrv_get_field.
$id = sqlsrv_get_field( $stmt, 0);
echo $id;
sqlsrv_close($conn);

